<!DOCTYPE html>
<%@page import="com.faeple.util.SessionManager"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ page language="java" contentType="text/html;  charset=utf-8" pageEncoding="utf-8"%>
<html lang="ko">
	<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
	
	<title>Faeple</title>
	
	<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
	<!--[if lt IE 9]>
		<script src="/resources/js/html5shiv.js"></script>
		<script src="/resources/js/respond.min.js"></script>
	<![endif]-->
	<link rel="stylesheet" href="/resources/css/font-awesome.css">
	<link rel="stylesheet" href="http://fonts.googleapis.com/earlyaccess/nanumgothic.css">
	<style type="text/css">
		body {
			color:#333;
		}
		.is_reply_ok { background-color: #3860FF; color:#fff; padding: 6px 12px; }
		.is_reply_no { background-color: #EC6666; color:#fff; padding: 6px 12px; }
	</style>
</head>
<body>
<%@ include file="menu.jsp" %>


<div class="container">
	<div class="page-header">
		<h2 id="tables">1:1문의 <small>&nbsp;${totalCount}개</small></h2>
    </div>
    <div>
    	<form method="get" action="/config/admin/inquiry" id="parameter">
    	<div style="height:40px; position: relative; margin-bottom:15px;">
    		<div style="float:left;" class="form-inline">
				<select class="form-control" id="order" name="order">
    				<option value="">정렬</option>
    				<option value="latest">최신순</option>
    				<option value="late">이전순</option>
    			</select>
    			<select class="form-control" id="is_reply" name="is_reply">
    				<option value="">답변여부</option>
    				<option value="true">답변</option>
    				<option value="false">미답변</option>
    			</select>
			</div>
    		<div style="float:right;">
    			<div style="position: relative;" class="form-inline">
	    			<select class="form-control" style="float: left; margin-right:5px;" id="searchType" name="searchType">
	    				<option value="id">아이디</option>
	    				<option value="email">이메일</option>
	    				<option value="title">제목</option>
	    				<option value="content">내용</option>
	    				<option value="idx">회원번호</option>
	    			</select>
					<div class="input-group" style="float: left; width: 200px;">
						<input type="text" class="form-control" id="searchValue" name="searchValue" value="${searchValue}">
						<span class="input-group-btn">
							<button class="btn btn-default" type="submit"><i class="fa fa-search"></i></button>
						</span>
					</div>
    			</div>
    		</div>
    	</div>
    	</form>
    	<div class="table-responsive">
		    <table class="table table-hover">
				<thead>
					<tr>
						<th>번호</th>
						<th>제목</th>
						<th>작성자</th>
						<th>회원번호</th>
						<th>이메일</th>
						<th>답변여부</th>
						<th>날짜</th>
					</tr>
				</thead>
				<tbody>
					<c:if test="${fn:length(inquirys) ne 0}">
					<c:forEach items="${inquirys}" var="item">
						<tr>
							<td>${item.idx}</td>
							<td><a href="inquiryView?idx=${item.idx}">${item.title}</a></td>
							<td>
								<c:choose>
									<c:when test="${item.member_id ne 'null'}">
										<a href="/${item.member_id}" target="_blank">${item.name}</a>
									</c:when>
									<c:otherwise>
										${item.name}
									</c:otherwise>
								</c:choose>
							</td>
							<td>${item.member_idx}</td>
							<td>${item.email}</td>
							<td>
								<c:choose>
									<c:when test="${item.is_reply eq 'true'}">
										<span class="is_reply_ok">답변</span>
									</c:when>
									<c:otherwise>
										<span class="is_reply_no">미답변</span>
									</c:otherwise>
								</c:choose>
							</td>
							<td>${item.createdate}</td>
						</tr>
					</c:forEach>
					</c:if>
					<c:if test="${fn:length(inquirys) eq 0}">
						<tr>
							<td colspan="7" style="text-align:center;">검색된 결과가 없습니다</td>
						</tr>
					</c:if>
				</tbody>
			</table>
		</div>
    </div>    
</div>

<div class="container" style="text-align:center; position:relative;">

<c:if test="${page.page_sno > 0}">
	<ul class="pager" style="position:absolute;top:0;width:97.5%;">
		<li class="previous"><a href="?pageno=1${parameter}">&larr; 처음</a></li>
		<li class="next"><a href="?pageno=${page.total_page}${parameter}">마지막 &rarr;</a></li>
	</ul>
	<ul class="pagination">
		<c:choose>
			<c:when test="${page.prev_pageno == 1 && page.group_no == 1}">
				<li class="disabled"><a href="#">&laquo;</a></li>
			</c:when>
			<c:otherwise>
				<li><a href="?pageno=${page.prev_pageno}${parameter}">&laquo;</a></li>
			</c:otherwise>
		</c:choose>
		<c:forEach begin="${page.page_sno}" end="${page.page_eno}" var="pgno" varStatus="status">
			<c:choose>
				<c:when test="${pgno == page.pageno}">
					<li class="active"><a href="?pageno=${pgno}${parameter}">${pgno}</a></li>
				</c:when>
				<c:otherwise>
					<li><a href="?pageno=${pgno}${parameter}">${pgno}</a></li>
				</c:otherwise>
			</c:choose>
		</c:forEach>
		<c:choose>
			<c:when test="${page.next_pageno == page.total_page}">
				<li class="disabled"><a href="#">&raquo;</a></li>
			</c:when>
			<c:otherwise>
				<li><a href="?pageno=${page.next_pageno}${parameter}">&raquo;</a></li>
			</c:otherwise>
		</c:choose>
	</ul>
</c:if>
</div>
</body>
<script src="/resources/js/jquery-1.11.0.js"></script>
<script src="/resources/js/jquery-ui-1.10.4.custom.min.js"></script>
<script src="/resources/js/bootstrap.js"></script>
<script type="text/javascript">
	$(function(){
		$(".navbar-nav").children("li").eq(5).addClass("active");
		
		if("${order}" == "latest"){
			$("#order option:eq(1)").attr("selected","selected");
		}else if("${order}" == "late"){
			$("#order option:eq(2)").attr("selected","selected");
		}
		
		if("${is_reply}" == "true"){
			$("#is_reply option:eq(1)").attr("selected","selected");
		}else if("${is_reply}" == "false"){
			$("#is_reply option:eq(2)").attr("selected","selected");
		}
		
		if("${searchType}" == "id"){
			$("#searchType option:eq(0)").attr("selected","selected");
		}else if("${searchType}" == "email"){
			$("#searchType option:eq(1)").attr("selected","selected");
		}else if("${searchType}" == "title"){
			$("#searchType option:eq(2)").attr("selected","selected");
		}else if("${searchType}" == "content"){
			$("#searchType option:eq(3)").attr("selected","selected");
		}else if("${searchType}" == "idx"){
			$("#searchType option:eq(4)").attr("selected","selected");
		}
		
		$("#order").change(function(){
			var order = $(this).val();
			if(order != ""){
				$("#parameter").submit();
			}else{
				//location.href = location.href.split("?")[0];
			}
		});
		
		$("#is_reply").change(function(){
			var is_reply = $(this).val();
			if(is_reply != ""){
				$("#parameter").submit();
			}else{
				//location.href = location.href.split("?")[0];
			}
		});
	});
</script>
</html>